package com.hh.userMager.user.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;


import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hh.userMager.user.dao.UserDao;
import com.hh.userMager.user.model.UserModel;
import com.hh.userMager.user.model.UserQueryModel;

@Service("us")
@Transactional
public class UserServiceImpl implements UserService {
	@Autowired
	private UserDao userDao;

	@Override
	public void add(UserModel u) {
		userDao.add(u);
	}

	@Override
	public void del(int operator_id) {
		userDao.del(operator_id);
	}

	@Override
	public void update(UserModel u) {
		userDao.update(u);
	}

	@Override
	public UserModel findById(int operator_id) {
		return userDao.findById(operator_id);
	}

	@Override
	public List<UserModel> findAll() {
		return userDao.findAll();
	}

	@Override
	public boolean checkName(UserQueryModel uq) {
		List<UserModel> usm = userDao.findByCondition(uq);
		if (usm != null && usm.size() > 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public List<UserModel> findByNameOrStatus(UserQueryModel uq) {
		return userDao.findByCondition(uq);
	}

}
